<?php
require_once './header.php';
require_once './core/sql.php';
$sql = new SqlS();


// 所有问题
if (isset($_GET['uid']) && isset($_GET['fid'])) {
    $x = 0;
    list($num, $array, $title) = $sql->searchFormInformation($_GET['uid'], $_GET['fid']);
    if ($num == 0) {
        $tip = '<li style="text-align: center; color: #F00;">⚠️该表格不存在哦⚠️</li>';
    } else {
        $tip = '<li style="text-align: center; color: #a0a0a0;">已经到底了</li>';
    }
    ?>
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="initial-scale=1.0,width=device-width,user-scalable=0,maximum-scale=1.0"/>
        <?php
        if (empty($title)) {
            ?>
            <title>🔥活动火热报名中！！！🔥</title>
            <?php
        } else {
            ?>
            <title><?= $title ?></title>
            <?php
        }
        ?>
        <title><?= $title ?></title>
        <link rel="stylesheet" href="./css/base.css">
        <link rel="stylesheet" href="./css/index.css">
        <link rel="stylesheet" href="./Mdate/needcss/Mdate.css">
        <link rel="stylesheet" href="./admin/css/jquery.xctips.css"/>
        <script>
            function adapte() {//适配
                var designWidth = 1080, rem2px = 100;
                document.documentElement.style.fontSize = window.innerWidth / designWidth * rem2px + "px";
            }
            adapte();
        </script>
    </head>
    <style>
        .get-success {
            position: absolute;
            z-index: 10000;
            width: 100%;
            height: 100%;
            background-color: rgba(255, 255, 255, 0.5);
            text-align: center;
        }

        .get-success img {
            position: relative;
            top: 20%;
            text-align: center;
        }

        .texts {
            position: relative;
            z-index: 2001;
            top: 50%;
            font-size: 0.5rem;
            text-align: center;
        }

        .texts u {
            color: #c22020;
        }

        .demo {
            display: flex;
            display: -webkit-flex;
            display: -moz-flex;
        }

        .demo > input {
            flex: 1;
            -webkit-flex: 1;
            -moz-flex: 1;
        }

        .demo > button {
            background-color: #c22020;
            color: #fff;
            width: 20%;
            border-radius: 3px;
            margin-right: 20px;
            font-size: 10px;
        }
    </style>
    <body>
    <div class="get-success" style="display: none;">
        <img style="display: none;" src="./images/bms.png">
    </div>
    <div class="texts" style="display: none;"></div>
    <div class="form bulid-form fs36">
    <ul class="lists flex">
        <?php
        for ($i = 0; $i < $num; $i++) {
            list($quName, $quType, $quModes, $quBaText) = $array[$i];
            switch ($quType) {
                case '1':
                    // 单选
                    $modes_selects_array = json_decode($quModes);
                    $modes_selects_count = count($modes_selects_array);
                    ?>
                    <li>
                        <span class="on-name"><?= $quName ?></span>
                        <div class="radio">
                            <?php
                            for ($m = 0; $m < $modes_selects_count; $m++) {
                                if ($modes_selects_array[$m] != '') {
                                    if ($m == 0) {
                                        ?>
                                        <span class="active" onclick="setTimeout(updateIText, 100)">
                                        <?= $modes_selects_array[$m] ?>
                                        </span>
                                        <?php
                                    } else {
                                        ?>
                                        <span onclick="setTimeout(updateIText, 100)">
                                        <?= $modes_selects_array[$m] ?>
                                        </span>
                                        <?php
                                    }
                                }
                            }
                            ?>
                        </div>
                    </li>
                    <?php
                    break;
                case '2':
                    $x++;
                    // 多选
                    $modes_selects_array = json_decode($quModes);
                    $modes_length = count($modes_selects_array);
                    ?>
                    <li class="checkbox">
                        <span class="do-name"><?= $quName ?>选择</span><span>(可多选)</span>
                        <ul class="flex fs36 ab<?= $x ?>">
                            <?php
                            for ($n = 0; $n < $modes_length; $n++) {
                                if ($modes_selects_array[$n] != '') {
                                    if ($n == 0) {
                                        ?>
                                        <li class="active"
                                            onclick="setTimeout(updateIText, 100)"><?= $modes_selects_array[$n] ?></li>
                                        <?php
                                    } else {
                                        ?>
                                        <li onclick="setTimeout(updateIText, 100)"><?= $modes_selects_array[$n] ?></li>
                                        <?php
                                    }
                                }
                            }
                            ?>
                        </ul>
                    </li>
                    <?php
                    break;
                case '3':
                    // 单行文本
                    $modes_selects_array = json_decode($quModes);
                    ?>
                    <li>
                        <span class="qu-name"><?= $quName ?></span>
                        <input class="iText" type="text" placeholder="<?= $quBaText ?>"
                               maxlength="<?= $modes_selects_array[0] ?>" value=""
                               onchange="setTimeout(updateIText, 100)">
                    </li>
                    <?php
                    break;
                case '5':
                    // 日期
                    $modes_selects_array = json_decode($quModes);
                    ?>
                    <li class="demo">
                        <span class="qu-name"><?= $quName ?></span>
                        <input class="iText" type="text" id="dateSelectorDate" placeholder="<?= $quBaText ?>"
                               maxlength="<?= $modes_selects_array[0] ?>" onchange="setTimeout(updateIText, 100)"
                               value="">
                        <button type="button" id="dateShowBtn">选择日期</button>
                    </li>
                    <?php
                    break;
                case '6':
                    // 单行数字
                    $modes_selects_array = json_decode($quModes);
                    ?>
                    <li>
                        <span class="qu-name"><?= $quName ?></span>
                        <input class="iText" onkeyup="value=value.replace(/[^\d]/g,'')" type="text"
                               maxlength="<?= $modes_selects_array[0] ?>" value="" placeholder="<?= $quBaText ?>"
                               onchange="setTimeout(updateIText, 100)">
                    </li>
                    <?php
                    break;
                case '7':
                    //手机
                    $modes_array = json_decode($quModes);
                    ?>
                    <li>
                        <span class="qu-name"><?= $quName ?></span>
                        <input class="iText" type="text" onkeyup="value=value.replace(/[^\d]/g,'')" type="text"
                               maxlength="<?= $modes_array[0] ?>" value="" placeholder="<?= $quBaText ?>"
                               onchange="setTimeout(updateIText, 100)">
                    </li>
                    <?php
                    break;
                default :
            }
        }
        ?>
        <?= $tip ?>
    </ul>
    <div class="btn">
        <button><a href="javascript:;" onclick="upload_form(<?= $_GET['uid'] ?>, <?= $_GET['fid'] ?>)">报名</a></button>
    </div>
    <?php
} else {
    echo '表格不存在！';
}
?>
</div>
    <script src='./script/jquery.js'></script>
    <script src='./script/index.js'></script>
    <script src="./Mdate/iScroll.js"></script>
    <script src="./Mdate/Mdate.js"></script>
    <script type="text/javascript" src="./admin/js/jquery.xctips.js"></script>
    <script type="text/javascript">
        //为 tips 提示框自定义 CSS,以下为默认
        xcsoft.tipsCss = {
            height: '44px',
            fontSize: '16px'
        };
        //隐藏、显示速度 ，默认 fast
        xcsoft.tipsHide = xcsoft.tipsShow = 100;
    </script>
    <script type="text/javascript">
        var oDate = new Date();
        var year = oDate.getFullYear();
        var month = oDate.getMonth() + 1;
        var day = oDate.getDate();
        try {
            new Mdate("dateShowBtn", {
                acceptId: "dateSelectorDate",
                beginYear: "2000",
                beginMonth: "1",
                beginDay: "1",
                endYear: year,
                endMonth: month,
                endDay: day
            })
        } catch (e) {
            console.log(e);
        }
    </script>
    <script></script>
</body>
    </html>
<?php
require_once './footer.php';

/*var oDate = new Date(); //实例一个时间对象；
var year = oDate.getFullYear();   //获取系统的年；
var month = oDate.getMonth() + 1;   //获取系统月份，由于月份是从0开始计算，所以要加1
var day = oDate.getDate(); // 获取系统日，
new Mdate("dateShowBtn", {
    acceptId: "dateSelectorDate",
        beginYear: "2000",
        beginMonth: "1",
        beginDay: "1",
        endYear: year,
        endMonth: month,
        endDay: day
    })*/